package com;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:冒泡排序（递归）
 * User: YJ
 * Date: 2024-4-03
 * Time: 15:48
 */
public class BubbleExeRecursion {
    public static void main(String[] args) {
        int[] arr = new int[] {2,5,9,7,3,0};
        Bubble(arr,arr.length - 1);
        System.out.println(Arrays.toString(arr));
    }
    private static void Bubble(int[] array,int j) {
        if (j == 0) return;
        int x = 0;
        for (int i = 0; i < j; i++) {
            if (array[i] > array[i + 1]) {
                int t = array[i];
                array[i] = array[i + 1];
                array[i + 1] = t;
                x = i;
            }
        }
        Bubble(array,x);
    }
}
